package loop;

public class BuyChicken {

    public static void main(String[] args) {
        int gjNum; //公鸡的数量
        int mjNum; //母鸡的数量
        int xjNum; //小鸡的数量
        int iCount = 0;
        for (gjNum = 0; gjNum <= 20; gjNum++) {
            for (mjNum = 0; mjNum <= 33; mjNum++) {
                for (xjNum = 0; xjNum <= 100; xjNum++) {
                    //小鸡必须是3的倍数
                    if (xjNum % 3 == 0) {
                        if (gjNum * 5 + mjNum * 3 + xjNum / 3 == 100 && gjNum + mjNum + xjNum == 100) {
                            iCount++;
                            System.out.println("公鸡买" + gjNum + "只,母鸡买" + mjNum + "只,小鸡买" + xjNum + "只.");
                        }
                    }
                }
            }
        }

        System.out.println("一共有" + iCount + "种买法");
    }
}
